<include file="Index:header"/>
<div class='content_box'>
    <!-- page content start -->

    <link rel="stylesheet" href="{:RES}/jfb/css/addressform.css">
    <script type="text/javascript">
    function page_onload(){
        //此方法在页面加载完毕后调用
        $('.address_btn>span').on('click',function(){
            var wechat_id = "{$wechat_id}";
            var name = $('#name').val();
            var phonenum = $('#phonenum').val();
            var area = $('#area').val();
            var address = $('#address').val();
            var checkstatus = 1;
            if(!name){
                alert('请输入收件人姓名');
                checkstatus = 0;
            }
            if(!isValidMobile(phonenum)){
                alert('请输入正确的收件人手机号码');
                checkstatus = 0;
            }
            if(!area){
                alert('请输入收件所在区域');
                checkstatus = 0;
            }
            if(!address){
                alert('请输入收件详细地址');
                checkstatus = 0;
            }
            if(checkstatus){
                $.ajax({
                    type: "POST",
                    url: "/Wap/Api/exchangePrize.html",
                    data: {
                        wechat_id:wechat_id,
                        name:name,
                        phonenum:phonenum,
                        area:area,
                        address:address
                    },
                    dataType: "json",
                    success: function(data){
                        if(data.success==0){
                            alert(data.code);
                        }else{
                            var okfunction = function(){
                                window.location.href = '/Wap/Index/index.html';
                            }
                            showAlertOk('您已兑换成功',okfunction);
                        }
                    }
                });
                
            }
        });
        
    }
    function isValidMobile(mobile){
        var partten = /^1[3,5,8]\d{9}$/;
        if(partten.test(mobile))
            return true;
        else
            return false;
    }
    </script>
    <div class='address_input_box'>
        <div class='alert_address_input'>
            <span>收件人:</span>
            <input type="text" name="name" id="name" placeholder="请输入收件人姓名" />
        </div>
        <div class='alert_address_input'>
            <span>手机号码:</span>
            <input type="text" name="phonenum" id="phonenum" placeholder="请输入收件人手机号码" />
        </div>
        <div class='alert_address_input'>
            <span>所在区域:</span>
            <input type="text" name="area" id="area" placeholder="请输入收件所在区域(市/县/区)" />
        </div>
        <div class='alert_address_input'>
            <span>详细地址:</span>
            <input type="text" name="address" id="address" placeholder="请输入收件详细地址" />
        </div>
    </div>
    <div class='address_btn'>
        <span>确认兑换</span>
    </div>

    <!-- page content end -->
</div>
<include file="Index:footer"/>